package com.whut.mapper;

import com.whut.entity.UserList;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserListMapper {
    @Select("SELECT * FROM user")
    List<UserList> getAllUserList();

    @Select("SELECT * FROM user WHERE id = #{id}")
    UserList getUserListById(int id);

    @Select("SELECT * FROM user WHERE username LIKE CONCAT('%', #{username}, '%')")
    List<UserList> getUserListByUsername(String username);

    @Insert("INSERT INTO user (date, username, province, city, address, zip) VALUES (#{date}, #{username}, #{province}, #{city}, #{address}, #{zip})")
    void addUserList(UserList userList);

    @Update("UPDATE user SET date = #{date}, username = #{username}, province = #{province}, city = #{city}, address = #{address}, zip = #{zip} WHERE id = #{id}")
    void updateUserList(UserList userList);

    @Delete("DELETE FROM user WHERE id = #{id}")
    void deleteUserList(int id);
}
